import 'package:flutter_native_splash/flutter_native_splash.dart';
import 'package:smart_ai_dart/utils/storage.dart';

class CommonUtils {
  static const String appName = 'Launch Scheme';

  static const String appVersion = '1.0.0';

  static const String appBuildNumber = '1';

  static const String appBundleId = 'com.example.launchscheme';

  static const String appScheme = 'launchscheme';

  static const String appUrl = 'https://example.com';

  static const String appEmail = 'example@example.com';

  static Future<String> getAppVersion() async {
    return appVersion;
  }

  static Future<String> getAppBuildNumber() async {
    return appBuildNumber;
  }

  static Future<String> getAppBundleId() async {
    return appBundleId;
  }

  // 检查是否是首次启动
  static Future<bool> checkFirstLaunch() async {
    bool isFirstTime = StorageUtils.shared.getBool('isFirstLaunch') ??
        true; // 读取标记，默认 true（首次）

    if (isFirstTime) {
      // 延迟 3 秒后隐藏启动页
      await Future.delayed(const Duration(seconds: 3), () {
        FlutterNativeSplash.remove();
      });
      await StorageUtils.shared.setBool('isFirstLaunch', false);
    }

    return isFirstTime;
  }
}
